<?php
    function getAbsolutePath($url, $relative_url){
    	/**
    	 * Takes a URL, and retrieves the path minus the file.
    	 * Probably not the most efficient way to do this
    	 * @param string $url URL to retrieve the path from
    	 * @param integer $relative_url url we have read in; need to check for levels up (e.g., '../../..')
    	 * @return string
    	 */
    	
    	//check how many levels up we should go, if any
    	$count = substr_count($relative_url, '../');
    	
    	//remove the http:// part (and store it, in case its something else, like https)
    	$protocol = $pieces = explode('//', $url);
    	$url 	  = $protocol[1];
    	$protocol = $protocol[0] . "//";

    	$pieces = explode('/', $url);

    	$ret = '';
	
    	//if there is only one $piece, then the for-loop below won't work right
    	if(count($pieces) == 1)
    		return $protocol . $pieces[0] . "/";
    	
    	for($i = 0; $i < count($pieces) - ($count + 1); $i++){
    		$ret .= $pieces[$i] . "/";
    	}
    	return $protocol .= $ret;
    }
    
    function getHost($url){
    	/**
    	 * Takes a URL and returns the host
    	 * @param string $url the URL to retrieve the host from
    	 * @return string
    	 */
    	
    	//store the protocol
    	$pieces = explode('//', $url);
    	$path     = $pieces[1];
    	$protocol = $pieces[0] . "//";
    	
    	//get the host
    	$host = explode('/', $path);
    	
    	return $protocol . $host[0];
    }
    
    function validText($text, $ignore){
    	/**
    	 * Returns true if $text is not found in $ignore 
    	 * $ignore is a comma delimitted list of words to be ignored
    	 * @param string $text a text string we want to test
    	 * @param string $a list of words that, if found, should return false
    	 * @return boolean
    	 */
    	
    	$ignore = explode(',', $ignore);
    	foreach($ignore as $i){
    		//echo "Checking-$text-and-$i-(" . strstr($text, $i) . ")<br>";
    		if(!strstr(trim($text), trim($i)) === FALSE){
    			return false;
    		}
    	}
    	
    	return true;
    }
?>